﻿using Microsoft.EntityFrameworkCore;
using System;
using TestEFAbstractEntity.Entities;

namespace TestEFAbstractEntity
{
    public class Repository : DbContext
    {
        public Repository(DbContextOptions<Repository> options):base(options)
        {
            Console.WriteLine("初始化资源库");
        }
        protected DbSet<WorkNode> WorkNodes { get; set; }
        public DbSet<SimpleWorkNode> SimpleWorkNodes { get; set; }
        public DbSet<ParalleNode> ParalleNodes { get; set; }
        public DbSet<WorkNodeEvent> WorkNodeEvents { get; set; }
        public DbSet<CountersignNode> CountersignNodes { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<WorkNode>(p =>
            {
                p.HasKey(p => p.Id);
            });

            modelBuilder.Entity<WorkNodeEvent>(p => {
                p.HasKey(p => p.Id);
            });

            //modelBuilder.Entity<ParalleNode>(p => {
            //    p.HasKey(p => p.Id);
            //});

            //modelBuilder.Entity<CountersignNode>(p => {
            //    p.HasKey(p => p.Id);
            //});
        }
    }
}
